package com.huitu.whht.base.core.api.geo.pdo;

import com.huitu.api.rest.AbstractApiResource;
import com.huitu.commons.PageUtils;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiResource;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiService;
import com.huitu.whht.api.core.common.response.ApiResultBuilder;
import com.huitu.whht.base.core.api.geo.pdo.entities.GeoPdoQo;
import com.huitu.whht.base.core.api.geo.pdo.service.IGeoPdoCoreService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * 说明：入河排污口空间信息表，表名称：GEO_PDO_5T<br/>
 * 日期：2018-07-24
 *
 * @author ZhangPeng
 */
@Component
@SzyCoreApiResource
@Path("geo/pdo")
public class GeoPdoCoreResource extends AbstractApiResource {

    private static final Logger logger= LoggerFactory.getLogger(GeoPdoCoreResource.class);

    private  static  final  String UUID="acb5b57f-e322-463b-979b-69a07a872d9f";
    @Autowired
    @SzyCoreApiService
    private IGeoPdoCoreService geoPdoCoreService;
    @Override
    public String getUUID() {
        return UUID;
    }

    /**
     * @api {get} geo/pdo/{pdoCd:\\w{12}} [R]根据主键查询
     * @apiDescription 根据主键查询GEO_PDO_5T入河排污口空间信息数据
     * @apiName select by primary key
     * @apiGroup GEO_S03_0018-入河排污口空间信息
     * @apiVersion 1.0.0
     * @apiSampleRequest geo/pdo/420626000046
     * @apiParam {String}         pdoCd              【必须】入河排污口代码
     * @apiSuccess {String}         pdoCd              入河排污口代码
     * @apiSuccess {String}         pdoNm              入河排污口名称
     * @apiSuccess {String}         lgtd               经度
     * @apiSuccess {String}         lttd               纬度
     * @apiSuccess {String}         shape              空间信息
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "pdoCd": "420626000046",
     * "pdoNm": "楚烽公司排污口",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)",
     * "__index": 0
     * }
     * }
     * @apiUse exceptions
     */
    @GET
    @Path("{pdoCd:\\w{12}}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectByPrimaryKey(@PathParam("pdoCd") String pdoCd){
        logger.info("根据主键查询 入河排污口空间信息，参数 pdoCd:{}",pdoCd);
        return Response.ok(ApiResultBuilder.create(this,geoPdoCoreService.selectByPrimaryKey(pdoCd))).build();
    }

    /**
     * @api {post} geo/pdo/list [R]根据条件查询(含空间信息)
     * @apiDescription 根据条件查询GEO_PDO_5T入河排污口空间信息数据(含空间信息)
     * @apiName select by filter
     * @apiGroup GEO_S03_0018-入河排污口空间信息
     * @apiVersion 1.0.0
     * @apiSampleRequest geo/pdo/list
     * @apiParam {List(String)}   pdoCdList          (数组)入河排污口代码
     * @apiParam {String}         pdoCd              入河排污口代码
     * @apiParam {String}         pdoNm              入河排污口名称
     * @apiParam {String}         addr               地址
     * @apiParam {List(String)}   pdoTpList          (数组)入河排污口性质
     * @apiParam {Date}           compDtBgTm         (开始时间)建成日期
     * @apiParam {Date}           compDtEdTm         (结束时间)建成日期
     * @apiParam {List(String)}   emisTpList         (数组)排放方式
     * @apiParam {List(String)}   inRvTpList         (数组)入河方式
     * @apiParam {Double}         desPollCapMin      (最小)设计日排污能力
     * @apiParam {Double}         desPollCapMax      (最大)设计日排污能力
     * @apiParam {List(String)}   runCondList        (数组)运行状况
     * @apiParam {Date}           tsBgTm             (开始时间)时间戳
     * @apiParam {Date}           tsEdTm             (结束时间)时间戳
     * @apiParam {String}         nt                 备注
     * @apiParam {List(String)}   powTpList          (数组)污水分类
     * @apiParam {List(String)}   emisCycList        (数组)间歇或季节性排放周期
     * @apiParam {List(Integer)}  cycDnumList        (数组)周期内排放次数
     * @apiParam {List(String)}   pdoScaList         (数组)入河排污口规模
     * @apiParam {List(String)}   perStuList         (数组)许可状态
     * @apiParam {List(String)}   morCheList         (数组)监督性监测状态
     * @apiParam {Integer}        pdoSizeMin         (最小)排污口截面积
     * @apiParam {Integer}        pdoSizeMax         (最大)排污口截面积
     * @apiSuccess {String}         pdoCd             入河排污口代码
     * @apiSuccess {String}         pdoNm             入河排污口名称
     * @apiSuccess {String}         lgtd              经度
     * @apiSuccess {String}         lttd              纬度
     * @apiSuccess {String}         shape             空间信息
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "pdoCd": "420626000046",
     * "pdoNm": "楚烽公司排污口",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)"
     * },
     * {
     * "pdoCd": "420607000020",
     * "pdoNm": "朱集镇白河排污口",
     * "lgtd": 112.337416666667,
     * "lttd": 32.2657222222222,
     * "shape": "POINT (112.337416666667 32.2657222222222)"
     * }]
     * }
     * @apiSuccessExample 分页请求:
     * request header: Rang={max=50;size=50;field=TS DESC}
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "pdoCd": "420626000046",
     * "pdoNm": "楚烽公司排污口",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)",
     * "rowId": 1
     * },
     * {
     * "pdoCd": "420607000020",
     * "pdoNm": "朱集镇白河排污口",
     * "lgtd": 112.337416666667,
     * "lttd": 32.2657222222222,
     * "shape": "POINT (112.337416666667 32.2657222222222)",
     * "rowId": 2
     * }],
     * "paging": {
     * "count": 3,
     * "total": 120,
     * "finale": false,
     * "index": 1
     * }
     * }
     * @apiUse header_rang
     * @apiUse exceptions
     */
    @POST
    @Path("list")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectList(GeoPdoQo filter){
        PageUtils.startPageFromRang();
        logger.info("根据条件查询 入河排污口空间信息，参数 GeoPdoQo:{}",filter);
        return Response.ok(ApiResultBuilder.create(this,geoPdoCoreService.selectList(filter))).build();
    }
}
